<template>
	<view id="app">
		<view class="top">
			<view>
				<image src="https://i.loli.net/2021/07/23/L4AyHUOrs2Jk8fb.jpg" mode=""></image>
				<view class="">
					<text>小哥哥</text>
				</view>
				<view class="">
					<text>普通用户</text>
				</view>
			</view>
		</view>
		<view class="tab">
			<view :class="{'active':isCollect}" @click="showCollect">
				<text>我的收藏</text>
			</view>
			<view :class="{'active':isLost}" @click="showLost">
				<text>我的失物招领</text>
			</view>
			<view :class="{'active':isNew}" @click="showNew">
				<text>我的新鲜事</text>
			</view>
		</view>
		<view class="main">

			<!-- 收藏 -->
			<view v-show="isCollect">
				<view class="collect" v-for="(item, index) in list" :key="item.id">
					<image :src="item.src"></image>
					<text class="iconfont icon-xingzhuang60kaobei2 start"></text>
					<view>
						<text>{{ item.name }}</text>
						<text :data-id="item.id">报名</text>
					</view>
				</view>
			</view>

			<!-- 失物招领 -->
			<view v-show="isLost">
				<view class="lost" v-for="(item,index) in lostList" :key="index" @click="goDetail(item.id)">
					<view class="msgHeader">
						<view class="msgHeaderR">
							<view class="">
								<image :src="item.img" mode=""></image>
							</view>
							<text>{{item.name}}</text>
						</view>
						<view class="msgHeaderL">
							<text>{{item.date}}</text>
							<text>{{item.time}}</text>
						</view>
					</view>
					<view class="msgBody">
						<view>
							<text>{{item.title}}</text>
						</view>
						<view>
							<text>{{item.content}}</text>
						</view>
					</view>
				</view>
				
			</view>
			<!-- 新鲜事 -->
			<view v-show="isNew">
				<view class="new">
					<view class="news">
						<view>
							<image src="https://i0.hdslb.com/bfs/album/bcb42f5b9942f12424822a53c8b1154751d124f5.jpg">
							</image>
						</view>
						<view>
							<view>
								<text>韩梅梅</text>
								<text>13:22</text>
							</view>
							<view>
								<view>开学第一天,感谢师兄鼎力相助!不然这么多东西我还真的搬不回去了。</view>
								<view>
									<view>
										<image style="width: 190rpx;height: 190rpx;"
											src="https://i0.hdslb.com/bfs/album/912edcc1e6b0ef248a9e96062da151be92d6e358.png">
										</image>
									</view>
									<view class="img">
										<image style="width: 190rpx;height: 190rpx;"
											src="https://i0.hdslb.com/bfs/album/e923f54a9b355bd88818cb8ea83ebcf099a642a2.png">
										</image>
									</view>
									<view class="img">
										<image style="width: 190rpx;height: 190rpx;"
											src="https://i0.hdslb.com/bfs/album/035e9420bd3d604b223c9250506b6cc62d2a5210.png">
										</image>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
						
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				/* 收藏 */
				list: [],
				/* 失物招领 */
				lostList: [],
				/* 是否显示 */
				isCollect: true,
				isLost: false,
				isNew: false
			}
		},
		methods: {
			//选项卡
			showCollect() {
				this.isCollect = true,
				this.isLost = false,
				this.isNew = false
			},
			showLost() {
				this.isCollect = false,
				this.isLost = true,
				this.isNew = false
			},
			showNew() {
				this.isCollect = false,
				this.isLost = false,
				this.isNew = true
			},
			//获取我的收藏
			async getCollect(){
				const {id} =uni.getStorageSync('myInfo')
				const {data:res} = await this.$http({
					url:'/user/myFavorites',
					id:id
				}) 
				console.log(res);
			},
			//获取我的失物招领
			async getList(){
				const {id} =uni.getStorageSync('myInfo')
				const {data:res} = await this.$http({
					url:'/user/myLastFound',
					id:id
				}) 
				console.log(res);
			},
			//获取我的新鲜事
			async getNew(){
				const {id} =uni.getStorageSync('myInfo')
				const {data:res} = await this.$http({
					url:'/user/myNewThing',
					id:id
				}) 
				console.log(res);
			}
		},
		mounted() {
			this.getCollect();
			this.getList();
			this.getNew();
		}
	}
</script>

<style lang="less">
	#app {
		.top {
			background-color: #f9cc66;
			height: 440rpx;
			width: 750rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			text-align: center;

			image {
				height: 120rpx;
				width: 120rpx;
				border-radius: 50%;
			}

			view:nth-child(2) {
				margin-top: 15rpx;

				text {
					font-size: 33rpx;
				}
			}

			view:nth-child(3) {
				margin-top: 15rpx;
				height: 50rpx;
				width: 140rpx;
				border-radius: 11rpx;
				border: 1rpx solid #22201a;
				line-height: 50rpx;

				text {
					font-size: 28rpx;
					color: #22201a;
				}
			}
		}

		.tab {
			height: 100rpx;
			width: 750rpx;
			display: flex;
			justify-content: space-around;
			line-height: 100rpx;
			
			.active{
				border-bottom: 4rpx solid #f9cc66;
			}
			view{
				
				text {
					font-size: 28rpx;
					color: #252525;
					cursor: none;
				}
			}
			
		}

		/* 内容区 */
		.main {
			padding: 30rpx;
			background-color: #f6f6f6;

			/* 收藏 */
			.collect {
				width: 690rpx;
				height: 422rpx;
				display: flex;
				flex-wrap: wrap;
				justify-content: center;
				align-items: center;
				position: relative;
				margin-bottom: 30rpx;
				border-radius: 20rpx;
				background-color: #FFFFFF;

				.start {
					position: absolute;
					top: 30rpx;
					right: 30rpx;
					font-size: 50rpx;
					color: yellow;
					z-index: 9999;
				}

				image {
					width: 690rpx;
					height: 300rpx;
				}

				>view {
					width: 632rpx;
					height: 122rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

					text {
						font-size: 30rpx;
						font-weight: bold;
					}

					text:last-child {
						width: 166rpx;
						height: 60rpx;
						background-color: #f9cc66;
						display: flex;
						justify-content: center;
						align-items: center;
						border-radius: 50rpx;
					}
				}
			}
		}

		/* 失物招领 */
		.lost {

			.msgHeader {
				display: flex;
				justify-content: space-between;
				height: 80rpx;
				line-height: 80rpx;

				>.msgHeaderR {
					display: flex;

					image {
						height: 80rpx;
						width: 80rpx;
						border-radius: 50%;
					}

					text {
						transform: translateX(20rpx);
						font-size: 30rpx;
					}
				}

				>.msgHeaderL {

					>text:nth-child(1) {
						margin-right: 20rpx;
					}

					>text {
						color: #b4b3b3;
						font-size: 20rpx;
					}
				}
			}

			.msgBody {
				padding-bottom: 15rpx;
				border-bottom: 1px solid #ebebeb;
				margin-left: 100rpx;

				>view {
					margin: 15rpx 0;
				}

				>view:nth-child(1) {
					font-size: 30rpx;
				}

				>view:nth-child(2) {
					color: #717171;
					font-size: 25rpx;
				}
			}
		}

		/* 新鲜事 */
		.new {
			margin-bottom: 120rpx;

			.news {
				display: flex;
				margin-bottom: 40rpx;

				>view:first-child {
					width: 80rpx;
					height: 80rpx;
					border-radius: 40rpx;

					image {
						width: 80rpx;
						height: 80rpx;
						border-radius: 40rpx;
					}
				}

				>view:last-child {
					padding-left: 20rpx;

					>view:first-child {
						width: 590rpx;
						height: 80rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;

						>text:first-child {
							font-size: 32rpx;
							font-weight: bold;
						}

						>text:last-child {
							font-size: 24rpx;
							color: #b4b3b3;
						}
					}

					>view:last-child {
						display: flex;
						flex-direction: column;

						>view:first-child {
							width: 590rpx;
							font-size: 28rpx;
							color: #b4b3b3;
							line-height: 50rpx;
							margin-bottom: 20rpx;
						}

						>view:last-child {
							display: flex;
							justify-content: space-between;
						}
					}
				}
			}
		}
	}
</style>
